var userInfo = {};
userInfo = getTopWindow().userInfo;

$(function () {
    // 初始化表格
    loadInit();
});


// 初始化表格
function loadInit() {
    loadMask();
    var objs = fromToJson("searchForm"); // 定义一个对象 存放保存对象

    $JQGrid.init({
        "id": "lawyerAbroad-list-table",
        "useCheckAll": false,
        colNames: ['序号', '姓名', '法律工作角色', '所属组织', '信息更新时间'],// jqGrid的列显示名字
        colModel: [ //jqGrid每一列的配置信息。包括名字，索引，宽度,对齐方式.....
            {
                name: 'lawyerInfoId',
                index: 'lawyerInfoId',
                hidden: true,
            },
            {
                name: 'lawyerName',
                index: 'lawyerName',
                sortable: false,
                formatter: function (cellvalue, options, rowObject) {
                    return "<span class='grid-opt' onclick=detaiLawyerAbroad('" + rowObject.lawyerInfoId + "')>"+cellvalue+"</span>";
                }
            },
            {
                name: 'lawyerPost',
                index: 'lawyerPost',
                sortable: false,
            },
            {
                name: 'projectName',
                index: 'projectName',
                hidden: false,
            },
            {
                name: 'modifyTime',
                index: 'modifyTime',
                sortable: false,
            },
            /*{
                name: 'operation',
                index: 'operation',
                sortable: false,
                title: false,
                select: false,
                align: "center",
                formatter: function (cellvalue, options, rowObject) {
                    return "<span class='grid-opt' onclick=updateByPrimaryKeySelective('" + rowObject.lawyerInfoId + "')>编辑</span>"+
                        "<span class='grid-opt' onclick=removeLawyerAbroad('" + rowObject.lawyerInfoId + "')>删除</span>";
                }
            }*/],
        "dataUrl": "/lrm/lrmLawyerAbroad/queryProjectBaseInfoList",
        "datatype": "json",
        "data": objs,
        "jqObj": {
            "jsonReader": {
                "root": "data.list", page: "data.pageNum", total: "data.pages",
                records: "data.total", repeatitems: false, id: "lawyerInfoId"
            },// 设置返回数据格式
        }
    });
    closeMask();
}

//查询
function queryProjectBaseInfoList() {
    // 查询列表
    var objs = fromToJson("searchForm"); // 定义一个对象 存放保存对象
    $JQGrid.search("lawyerAbroad-list-table", objs);
}

//律师信息编辑
function updateByPrimaryKeySelective(lawyerInfoId) {
    window.location.href = '/lrm/html/lawyerabroad/updateLawyerAbroad.html?lawyerInfoId=' + lawyerInfoId;
}

//详情页面
function detaiLawyerAbroad(lawyerInfoId) {
    window.location.href = '/lrm/html/lawyerabroad/detailLawyerAbroad.html?lawyerInfoId=' + lawyerInfoId;
}
//律师信息添加
function insertLawyerAbroadInfo() {
    window.location.href = '/lrm/html/lawyerabroad/addLawyerAbroad.html?lawyerInfoId=';
}

//删除律师信息
function removeLawyerAbroad(lawyerInfoId) {
    layer.confirm("确定删除？", {
            icon: 3,
            title: '提示'
        },
        function () {
            // 确认后处理的事情，这里写入你要进行的操作：数据处理等；
            $.ajax({
                url: "/lrm/lrmLawyerAbroad/removeLawyerAbroad",
                type: 'post',
                async: false,
                data: {"lawyerInfoId": lawyerInfoId},
                success: function (data) {
                    if (data && data.returnValue) {
                        layer.msg(message.delSuccess, {
                                time: 1500,
                                icon: 1
                            },
                            function () {
                                loadInit();
                            });
                    } else {
                        layer.msg(data.msg, {
                                time: 1500,
                                icon: 2
                            },
                            function () {
                            });
                    }
                },
                error: function () {
                    layer.msg(message.sysError, {time: 2000, icon: 2});
                }
            })
        });


}